package p270jp.pxv.android.viewholder;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import p014ae.C0135p4;
import p014ae.C0146r;
import p014ae.C0199z4;
import p014ae.View$OnClickListenerC0163u;
import p045be.C1060c;
import p071cd.Functions;
import p210hh.PixivAccountManager;
import p270jp.pxv.android.R;
import p270jp.pxv.android.activity.RecommendedUserActivity;
import p270jp.pxv.android.model.PixivUserPreview;
import p270jp.pxv.android.response.PixivResponse;
import p314lg.ViewHolderRecommendedUserBinding;
import p350mp.Timber;
import p521th.SolidItemViewHolder;
import p645yc.AndroidSchedulers;
import p665z6.C7468w;
import p671zc.CompositeDisposable;
import p671zc.Disposable;
import p677zi.PixivImageLoader;

@SuppressLint({"RxJava2MissingCompositeDisposableClear"})
/* renamed from: jp.pxv.android.viewholder.RecommendedUserViewHolder */
/* loaded from: classes2.dex */
public class RecommendedUserViewHolder extends SolidItemViewHolder {
    private final ViewHolderRecommendedUserBinding binding;
    private final CompositeDisposable compositeDisposable;
    private final PixivImageLoader pixivImageLoader;
    private List<PixivUserPreview> recommendedUserPreviews;
    private boolean requesting;

    public RecommendedUserViewHolder(CompositeDisposable aVar, ViewHolderRecommendedUserBinding k8Var, PixivImageLoader aVar2) {
        super(k8Var.f2666e);
        this.compositeDisposable = aVar;
        this.binding = k8Var;
        this.pixivImageLoader = aVar2;
    }

    /* renamed from: a */
    public static /* synthetic */ void m4398a(RecommendedUserViewHolder recommendedUserViewHolder) {
        recommendedUserViewHolder.lambda$onBindViewHolder$1();
    }

    public static RecommendedUserViewHolder createViewHolder(CompositeDisposable aVar, ViewGroup viewGroup, PixivImageLoader aVar2) {
        return new RecommendedUserViewHolder(aVar, (ViewHolderRecommendedUserBinding) C1060c.m10358a(viewGroup, R.layout.view_holder_recommended_user, viewGroup, false), aVar2);
    }

    /* renamed from: d */
    public static /* synthetic */ void m4397d(RecommendedUserViewHolder recommendedUserViewHolder, Disposable bVar) {
        recommendedUserViewHolder.lambda$onBindViewHolder$0(bVar);
    }

    /* renamed from: e */
    public static /* synthetic */ void m4396e(RecommendedUserViewHolder recommendedUserViewHolder, View view) {
        recommendedUserViewHolder.lambda$setRecommendedUserPreviews$4(view);
    }

    /* renamed from: h */
    public static /* synthetic */ void m4395h(RecommendedUserViewHolder recommendedUserViewHolder, PixivResponse pixivResponse) {
        recommendedUserViewHolder.lambda$onBindViewHolder$2(pixivResponse);
    }

    public /* synthetic */ void lambda$onBindViewHolder$0(Disposable bVar) {
        this.requesting = true;
    }

    public /* synthetic */ void lambda$onBindViewHolder$1() {
        this.requesting = false;
    }

    public /* synthetic */ void lambda$onBindViewHolder$2(PixivResponse pixivResponse) {
        setRecommendedUserPreviews(pixivResponse.userPreviews);
    }

    public static void lambda$onBindViewHolder$3(Throwable th) {
        Timber.f23100a.mo3514p(th);
    }

    public void lambda$setRecommendedUserPreviews$4(View view) {
        Context context = this.itemView.getContext();
        Context context2 = this.itemView.getContext();
        int i = RecommendedUserActivity.f18568b0;
        context.startActivity(new Intent(context2, RecommendedUserActivity.class));
    }

    private void setRecommendedUserPreviews(List<PixivUserPreview> list) {
        this.recommendedUserPreviews = list;
        this.itemView.setOnClickListener(new View$OnClickListenerC0163u(this, 28));
        if (list != null && list.size() > 3) {
            this.pixivImageLoader.m60f(this.itemView.getContext(), list.get(0).user.profileImageUrls.getMedium(), this.binding.f21841q);
            this.pixivImageLoader.m60f(this.itemView.getContext(), list.get(1).user.profileImageUrls.getMedium(), this.binding.f21842r);
            this.pixivImageLoader.m60f(this.itemView.getContext(), list.get(2).user.profileImageUrls.getMedium(), this.binding.f21843s);
        }
    }

    @Override // p521th.SolidItemViewHolder
    public void onBindViewHolder(int i) {
        if (!this.requesting) {
            List<PixivUserPreview> list = this.recommendedUserPreviews;
            if (list != null) {
                setRecommendedUserPreviews(list);
            } else {
                this.compositeDisposable.mo82c(PixivAccountManager.m5511e().m5514b().m989l(C7468w.f31300q).m986o(AndroidSchedulers.m334a()).m992i(new C0146r(this, 22)).m991j(new C0135p4(this, 1)).m984q(new C0135p4(this, 23), C0199z4.f698g, Functions.f5386c, Functions.f5387d));
            }
        }
    }
}
